package com.zego.wawaji.ui.dialog.pay;

import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zego.wawaji.R;
import com.zego.wawaji.ui.base.recycler.BaseRecyclerViewAdapter;
import com.zego.wawaji.ui.base.recycler.BaseRecyclerViewHolder;
import com.zego.wawaji.ui.bean.pay.Pay;

/**
 * 限购支付列表
 * Created by Su on 2017/12/26.
 */
public class PayLimitAdapter extends BaseRecyclerViewAdapter<Pay> {
    private int selectPosition = 0;

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.pay_limit_item};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, int position) {
        Pay pay = getItem(position);

        RelativeLayout payItem = viewHolder.findViewById(R.id.pay_item);
        payItem.setSelected(selectPosition == position);   // 选中状态

        TextView pr_coin = viewHolder.findViewById(R.id.pr_coin);
        TextView pr_money = viewHolder.findViewById(R.id.pr_money);
        TextView pr_desc = viewHolder.findViewById(R.id.pr_desc);

        pr_coin.setText(String.valueOf(pay.getWwCoinCz()));
        pr_money.setText(pay.getIntPrice() + Html.fromHtml("&#165;").toString());

        pr_desc.setVisibility(View.GONE);
        if (!TextUtils.isEmpty(pay.getRemark())) {
            pr_desc.setVisibility(View.VISIBLE);
            pr_desc.setText(pay.getRemark());
        }
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }

    public void updateData(int positon) {
        this.selectPosition = positon;
        notifyDataSetChanged();
    }
}
